<?php

require_once 'database.php';
require_once 'common.php';

session_start();
$intAccountId = getUserIdFromUsername($_SESSION['user']);

//Get information from the post
$strProjectName = $_POST['project_name'];
$dateStartDate = $_POST['start_date'];
$dateEndDate = $_POST['end_date'];
$intIterationLength = $_POST['iteration_length'];

//Insert new row into the database

$addProject = mysql_query("INSERT INTO project (account_id, project_name, start_date, end_date, iteration_length) VALUES ($intAccountId, '$strProjectName', '$dateStartDate', '$dateEndDate', $intIterationLength)")
	or die("Problem reading table: " . mysql_error());

$intProjectId = mysql_insert_id();

//Create the return object
$objReturn = array();
$objReturn['code'] = "SUCCESS";
$objReturn['project_id'] = $intProjectId;


header("content-type:application/json");
echo json_encode($objReturn);